package com.woniuxy.usersecurity.config;

import com.woniuxy.life.core.util.RsaUtils;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;

import javax.annotation.PostConstruct;
import java.security.PrivateKey;
import java.security.PublicKey;


@ConfigurationProperties("rsa.key")
@Data
public class RsaKeyProperties {
    //名称同配置文件相同
    private String pubKeyFile;
    private String priKeyFile;

    private PublicKey publicKey;
    private PrivateKey privateKey;

    @PostConstruct
    public void createRsaKey() throws Exception {
        publicKey= RsaUtils.getPublicKey(pubKeyFile);
        privateKey= RsaUtils.getPrivateKey(priKeyFile);
    }
}
